using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Easycmd
{
    internal class Dlg
    {
        public static bool Confirm(string message)
        {
            return MessageBox.Show(
                                message,
                                "Alert",
                                MessageBoxButtons.OKCancel) == DialogResult.OK;
        }
    }

    internal class SpecialFolderSelector : Form
    {
        ListBox list = new ListBox();
        Button ok = new Button();
        Button cancel = new Button();
        FlowLayoutPanel p = new FlowLayoutPanel();
        public SpecialFolderSelector()
            : base()
        {
            this.Controls.Add(list);
            this.Controls.Add(p);
            p.Controls.Add(cancel);
            p.Controls.Add(ok);
            p.Dock = DockStyle.Bottom;
            list.Dock = DockStyle.Fill;
            ok.DialogResult = DialogResult.OK;
            cancel.DialogResult = DialogResult.Cancel;
            ok.Text = "&OK";
            cancel.Text = "&Cancel";
            list.ValueMember = "Value";
            list.DisplayMember = "Display";
            list.DoubleClick += new EventHandler(list_DoubleClick);
            p.Height = 40;
            this.Height = list.Height + p.Height;
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        void list_DoubleClick(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }
        public void Fill(NameValue v)
        {
            list.Items.Add(v);

        }
        public object GetValue()
        {
            if (list.SelectedIndices.Count > 0)
                return list.Items[list.SelectedIndex];
            else
                return null;
        }
        public DialogResult ShowDialog(string caption)
        {
            Text = caption;
            return base.ShowDialog();
        }
    }
    internal class NameValue
    {
        public string Display;
        public object Value;
        public override string ToString()
        {
            return Display;
        }
    }

}
